#ifndef CRC16_H__
#define CRC16_H__

typedef struct Struct_CRC16_16 {
    char crcName[16];
    unsigned short crcPoly;
    unsigned short crcInit;
    unsigned short crcXor;
    unsigned short crcTable[16];
    unsigned char crcRefIn;
    unsigned char crcRefOut;
} CRC16_16;

typedef struct Struct_CRC16_256 {
    char crcName[16];
    unsigned short crcPoly;
    unsigned short crcInit;
    unsigned short crcXor;
    unsigned short crcTable[256];
    unsigned char crcRefIn;
    unsigned char crcRefOut;
} CRC16_256;

void create_crc16_table16(CRC16_16 * p_crc16_16);
void create_crc16_table256(CRC16_256 * p_crc16_256);
void prepare_crc16_with_table16(CRC16_16 * p_crc, unsigned short * crc16);
void process_crc16_with_table16(CRC16_16 * p_crc, const unsigned char * character, unsigned short * crc16);
void complete_crc16_with_table16(CRC16_16 * p_crc, unsigned short * crc16);
void prepare_crc16_with_table256(CRC16_256 * p_crc, unsigned short * crc16);
void process_crc16_with_table256(CRC16_256 * p_crc, const unsigned char * character, unsigned short * crc16);
void complete_crc16_with_table256(CRC16_256 * p_crc, unsigned short * crc16);
unsigned short generate_crc16(void *p_crc, unsigned int crc_table_size, const unsigned char * data, unsigned int length);

#endif //CRC16_H__
